package com.jeasonzhao.commons.basic;

public class StringPair
{
    private String id = null;
    private String name = null;
    public StringPair(String nId,String strName)
    {
        this.id = nId;
        this.name = strName;
    }

    public StringPair(StringPair x)
    {
        if(null != x)
        {
            this.id = x.id;
            this.name = x.name;
        }
    }

    public String getFirst()
    {
        return id;
    }

    public String getSecond()
    {
        return name;
    }

    public String getId()
    {
        return id;
    }

    public String getName()
    {
        return name;
    }

    public String getKey()
    {
        return id;
    }

    public String getValue()
    {
        return name;
    }

    public void setName(String s)
    {
        name = s;
    }

    public boolean equals(StringPair type)
    {
        return type != null &&
            null != this.id &&
            this.id.equals(type.getId());
    }

    public int hashCode()
    {
        return null == this.id ? super.hashCode() : this.id.hashCode();
    }

    public boolean equals(Object obj)
    {
        if(null == obj)
        {
            return false;
        }
        if(obj instanceof StringPair)
        {
            return this.equals((StringPair) obj);
        }
        else
        {
            return obj.toString().equals(this.id);
        }
    }

    public String toString()
    {
        return "{" + this.id + "=" + this.name + "}";
    }
}
